<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
	    *{
	    	margin: 0px;
	    	padding: 0px;
	    	list-style: none;
	    }

		#b::after{
			content:"" ;
			display: block;
			clear: both;
		}

		#b>li{
			margin-right: 10px;
			background: grey;
			cursor: pointer;
	        float: left;
		}

		#b ul{
			cursor: pointer;
			display: none;
		}

		#b .c{
			background: orange;
		}

		#b li>.c{
			display: block;
		}
	</style>
</head>
<body>
	
	<ul id="b">
		<li>选项1
			<ul>
				<li>1233321</li>
				<li>2</li>
				<li>3</li>
			</ul>
		</li>
		<li>选项2
			<ul>
				<li>4</li>
				<li>5</li>
				<li>6</li>
			</ul>
		</li>
		<li>选项3</li>
	</ul>

	<script>
		var ob=document.getElementById('b');
		var oli=ob.children;

	
			for(var i=0;i<oli.length;i++){	
				oli[i].onmouseenter=function(){
				this.children[0].setAttribute('class','c');
			}
               
                oli[i].onmouseleave=function(){
                	this.children[0].removeAttribute('class','c');
                }
		}
	</script>

</body>
</html>